Produces a key value for looking up in a crosswalk.
If value is None than returns an empty string. >>> v = None >>> key_as_str(v) + ‘XXX’ XXX
If value is a basestring removes leading and trailing whitespace if inner_trim = True, multiple line spaces made into one space, value is lowered: >>> v = ‘ DS sS ‘ >>> key_as_str(v) ds ss
If inner_trime is false just strim leading and trailing and lower >>> v = ‘ DF sdsD’ >>> v df sdsd
Helper function to check if file or directory is valid.
Escape a regular expression.
>>> re_escape(ab(#))
u'ab\((\d+|#\d+|#)\)'
This function integrates memoization, an optimization technique, into cardsharp. Memoize wraps a function with a single argument. When it is called the first time, the result is cached with the argument as the key. If it is called in the future with the same argument, it returns the cached value.
>>> from random import random
>>> func = lambda x: random()
>>> func(1) == func(1)
False
>>> func = memoize(func)
>>> func(1) == func(1)
True
Converts a string to a boolean.
If s is None returns None instead.
>>> str_to_boolean('1')
True
>>> str_to_boolean(0)
False
>>> str_to_boolean(' FAlse ')
False
>>> str_to_boolean('3')
Traceback (most recent call last):
...
FormatError: Invalid input data, 3: must be true, false, 1 or 0
Copy output file to review directory and return the path to the review directory
Helper funtion to ensure that cradsharp is able to handle the format arg.